#include<stdio.h>
#define BUFFS 102400 
int cpfile( char *srcfile, char *dstfile){

	char buff[102400];
	FILE *src,*dst;
	size_t readsize;

	printf("copyfile from '%s' to '%s'",srcfile,dstfile);

	src = fopen(srcfile,"r");
	dst = fopen(dstfile,"w");
	
	readsize = fread(buff,1,sizeof(buff),src);
	printf("readsize = %d\n",(int)readsize);
	
/*
	if(feof(src)){ printf("End of file\n");}
	if(ferror(src)){printf("Error reading\n");}
*/
	
	fwrite(buff,1,readsize,dst);
	return 0;
}

int main(int argc,char **argv){

	if(argc != 3){
		fprintf(stderr,"usage: %s srcfile dstfile\n",argv[0]);
		exit(-1);
	}

	if(cpfile(argv[1],argv[2]) != 0){
		fprintf(stderr,"Fail to copy file '%s' to '%s'\n",argv[1],argv[2]);
	}
	return 0;
}
